package top.lc951.myandroid.views.card2;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.Collections;
import java.util.List;

import top.lc951.myandroid.R;
import top.lc951.myandroid.model.CardOverlayModel;

public class Card2OverlayAdapter implements ICoverFlowAdapter {
    private LayoutInflater mInflater;
    Context context ;

    public Card2OverlayAdapter(Context context) {
        this.context=context;
        mInflater = LayoutInflater.from(context);
    }

    public List<CardOverlayModel> getList() {
        return list;
    }

    private List<CardOverlayModel> list = Collections.emptyList();

    public void setList(List<CardOverlayModel> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View rootView, ViewGroup container) {
        final CardOverlayModel itemObj = getList().get(position);

        if (null == rootView)
            rootView= mInflater.inflate(R.layout.live_banner_viewpager_item, null);
        ImageView imageView = rootView.findViewById(R.id.card_iv);
        if (null == imageView) {
            throw new RuntimeException("you should set a item layout");
        }
        if(!TextUtils.isEmpty(itemObj.getCoverUrl())){
            Glide.with(context)
                    
                    .load(itemObj.getCoverUrl())
                    .error(R.mipmap.ic_img02)
                    .into(imageView);
        }
        return rootView;
    }

    @Override
    public void getData(View view, int position) {

    }
}
